package user;

import inventory.InventoryItem;
import java.util.ArrayList;

/**
 * User class implements the user object which represents user account data
 * interaction with the database - this class is an interface to the user's real
 * account information in the database. The class implements various getters and
 * setters of a user's account information.
 *
 * @author Reynaldo Gonzales.
 * @version 1.0
 *
 */
public class User {

    //Defaults, for construction.
    public String username = "aUser";
    public String password = "aPassword";
    public String email = "name@domain.tld";
    public int id;
    private ArrayList<InventoryItem> inventoryArray = new ArrayList<InventoryItem>();
    private ArrayList<User> friendList = new ArrayList<User>();

    //Default constructor. User object, with an ID, Username, Password, and Email.
    public User(int i, String u, String p, String e) {
        id = i;
        username = u;
        password = p;
        email = e;
    }

    /**
     * addItemToInventoryArray implements the addition of an inventory object to
     * a user's inventory list.
     *
     * @param a Inventory Object to be added to the user's inventory list.
     *
     */
    public void addItemToInventoryArray(InventoryItem i) {
        inventoryArray.add(i);
    }

    /**
     * addFriendToFriendList implements the addition of a user object to a
     * user's friends list.
     *
     * @param a User Object to be added to the user's friends list.
     *
     */
    public void addFriendToFriendList(User u) {
        friendList.add(u);
    }

    /**
     * getFriendListSize returns the call-ee user object's friends list size.
     *
     * @return The size of a the call-ee user object friend's list.
     *
     */
    public int getFriendListSize() {
        return friendList.size();
    }

    /**
     * getFriend retrieves the index listing of the friends list of the call-ee
     * user object.
     *
     * @return A user object at the index of the call-see user's friends list.
     *
     */
    public User getFriend(int index) {
        return friendList.get(index);
    }

    /**
     * getInventoryArraySize returns the call-ee user object's inventory list
     * size.
     *
     * @return The size of a the call-ee user object's inventory list.
     *
     */
    public int getInventoryArraySize() {
        return inventoryArray.size();
    }

    /**
     * InventoryItem retrieves the index listing of the inventory list of the
     * call-ee user object.
     *
     * @return An inventory object at the provided index of the call-see user's
     * inventory list.
     *
     */
    public InventoryItem getItem(int index) {
        return inventoryArray.get(index);
    }

    /**
     * clearInventory clears the inventory array of the call-ee user object.
     *
     */
    public void clearInventory() {
        inventoryArray.clear();
    }

    /**
     * clearFriendList clears the friends array of the call-ee user object.
     *
     */
    public void clearFriendList() {
        friendList.clear();
    }
}